#include "supercap_task.h"
#include "main.h"
#include "string.h"

supcap_ctrl_t supcap_status;

void supercap_task(void const *pvParameters) {

    memset(&supcap_status, 0, sizeof(supcap_ctrl_t));


    while (1)
    {
        
        HAL_Delay(1000);
    }
    
}

int get_supercap_voltage(void) {

    if(supcap_status.voltage_B) return 0;

    int temp = 0;

    temp = (int)(((supcap_status.voltage_B * supcap_status.voltage_B * 3.3f) - 557.7f ) / 118.8f);

    temp = (temp>10) ? 10 : temp;
    temp = (temp<0) ? 0 : temp;

    return temp;

}